{include file='comdir/head.html'}
<body>
<div class="content">
	<div class="animated fadeInDown">
		<div class="pos"><a href="#" onClick="javascript :history.back(-1);">返回上一页</a></div>
		<div class="btn-box">
			<button class="btn btn-sm btn-success specialadd back_inline">添加专题</button>
		</div>
        <div class="searchBox">
            <form class="form-inline" action="javascript:void(0)">
                
                <span>
                 专题名称：<input type="text" class="form-control name " name="name" value="">
                </span>
                <span><input type="button" class="form-control btn-blue special_searh" value="搜索"></span>
                
            </form>
        </div>
		<div class="table_list_wrap">
			<div class="table-responsive">
				<table class="table table-bordered table-hover">
					<thead>
                        <tr>
                            <th>ID</th>
                            <th>名称</th>
                            <th>视频URL</th>
                            <th>创建人</th>
                            <th>创建时间</th>
                            <th>点击量</th>
                            <th>推荐|状态</th>
                            <th>操作</th>
                        </tr>
					</thead>
					<tbody class="listtbody">
                        {foreach from=$list item=vo}
                            <tr class="specialdel_{$vo.id}">
                                <td>{$vo.id}</td>
                                <td>{$vo.name}</td>
                                <td>{$vo.videourl}</td>
                                <td>{$vo.username}</td>
                                <td>{$vo.addtime|date_format:'%Y-%m-%d %H:%M:%S'}</td>
                                <td>{$vo.hits}</td>
                               
                                <td>
                                <span  data-infoid="{$vo.id}" {if $vo.recommend==1} class='btn-bgcolcor btn-bgcolor1 recommendflag1' {else} class='btn-bgcolcor btn-bgcolor1focus recommendflag0' {/if} onClick="recommendflag({$vo.recommend},this)">荐</span>
                                <span  data-infoid="{$vo.id}" {if $vo.status==1} class='btn-bgcolcor btn-bgcolor2 headflag1'  {else} class='btn-bgcolcor btn-bgcolor2focus headflag0'      {/if} onClick="statusfunc({$vo.status},this)">启</span>
                                </td>
                                <td>
                                    <input type="button" onclick="contenttype({$vo.id})" class="btn btn-xs btn-bgcolor1" value="专题分类">
                                    <input type="button" onclick="edit({$vo.id})" class="btn btn-xs btn-warning" value="编辑">
                                    <input type="button" onclick="del({$vo.id})" class="btn btn-xs btn-bgcolor3" value="删除">
                                    <input type="button" onclick="addArticle({$vo.id},'{$vo.name}')" class="btn btn-xs btn-bgcolor4" value="文章管理">
                                </td>
                            </tr>
                        {/foreach}
					</tbody>
				</table>
			</div>
		</div>
	</div>
    <div class="page-box">
            <div class="page">
                {$pageshow}
            </div>
        </div>
</div>
<script type="text/javascript">
    var _URL='{$_URL}';
    {literal}
    $(function(){
        //添加专题
        $('.specialadd').click(function(){
            window.location.href=_URL+"Special/add";
        });
        //专题搜索
        $('.special_searh').click(function(){
            ajaxpage(false);
        })
    });
    //编辑专题
    function edit(id){
        window.location.href=_URL+"Special/edit?id="+id;
    }
    //编辑推荐
    var recommendflagstatus=true;
    function recommendflag(value,objthis){
        var obj=$(objthis);
        var infoid=obj.attr('data-infoid');
        var recommendflag=0;
        if(value==0){recommendflag=1}
        var url=_URL+"Special/edit";
        if(recommendflagstatus===false){return false;}
        recommendflagstatus=false;
        _ajaxs.post(url,"recommendflag_ajaxs=1&recommend="+recommendflag+'&id='+infoid,function(data){
            layer.msg(data.msg,{icon: 1}, function(){
                if(data.status){
                    if(recommendflag==1){obj.addClass('btn-bgcolor');}
                    if(recommendflag==0){obj.addClass('btn-bgcolor1focus');}
                }
                recommendflagstatus=true;
            });
        });
    }
    //状态
    var headflagstatus=true;
    function statusfunc(value,objthis){
        var obj=$(objthis);
        var infoid=obj.attr('data-infoid');
        var headflag=0;
        if(value==0){headflag=1}
        var url=_URL+"Special/edit";
        if(headflagstatus===false){return false;}
        headflagstatus=false;
        _ajaxs.post(url,"status_ajaxs=1&status="+headflag+'&id='+infoid,function(data){
            layer.msg(data.msg,{icon: 1}, function(){
                if(data.status){
                    if(headflag==1){obj.addClass('btn-bgcolor2');}
                    if(headflag==0){obj.addClass('btn-bgcolor2focus');}
                }
                headflagstatus=true;
            });
        });
    }
    function ajaxpage(page){
        url='';
        url+=_sousuo.value('.name','name');
        if(page){
            url+="page="+page;
        }else{
            if(url!=''){
                url=url.substring(0,url.length-1);
            }
        }
        _ajaxs.post(_URL+"Special/lists",url,function _return(data){
            $('.listtbody').html('');
            $('.listtbody').html(data.data.list);
            if(data.data.pageshow){
                $('.page').html(data.data.pageshow);
            }else{
                $('.page').html('');
            }
        },'json')
    }
    
    function contenttype(id) {
        layer.open({
            type: 2,
            title: '专题内容分类',
            shadeClose: true,
            shade: false,
            maxmin: true, //开启最大化最小化按钮
            area: ['800px', '600px'],
            content: _URL+"Special/contentTypeList?id="+id
        });
    }
    function addArticle(id,name) {
        layer.open({
            type: 2,
            area: ['1000px', '600px'],
            title:name,
            fixed: false, //不固定
            maxmin: true,
            content: _URL+"Special/addArticles?id="+id
        });
    }
    function del(id){
        var url=_URL+"Special/del";
        var del_all=layer.confirm('确认要删除吗！', {btn: ['确认','取消'],'title':'专题'},function(){
            _ajaxs.post(url,'id='+id,function(data){
                if(data.status){
                    layer.msg(data.msg,{icon: 1}, function(){
                         $('.specialdel_'+id).remove();
                    });
                }else{
                    layer.msg(data.msg,{icon: 2}, function(){});
                }
            });
        });
    }
    {/literal}
</script>

</body>
</html>